package com.yyj.schedule;

import com.yyj.service.AppService;
import com.yyj.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class AccessTokenSchedule {

    public static Logger log = LoggerFactory.getLogger(AccessTokenSchedule.class);


    @Autowired
    AppService appService;

    /**
     *  处理AccessToken
     */
    @Scheduled(cron = "0 0 0/1 * * ?")
    private void initAccessToken(){
        try{
            log.info("initAccessToken>>>>>>"  , DateUtil.getNowLongTime());
            appService.initAccessToken();

        }catch(Exception e){
            log.error("initAccessToken error:{}" , e.getMessage() , e);
        }

    }
}
